home *** CD-ROM | disk | FTP | other *** search
- program AsyncRequester;
-
- uses Exec,AmigaDOS,Intuition;
-
- const
- ReqTitle : string[30] = 'Asynchron requester test'#0;
- ReqBody : string[30] = 'What are you waiting for?'#0;
- ReqGadgets : string[40] = 'PPC Amiga|B. Gates going bankrupt'#0;
-
- var
- req : pWindow;
- es : tEasyStruct;
-
- procedure Cleanup(mes: string);
- var
- rc : long;
- begin
- rc:=RETURN_OK;
- if mes<>'' then
- begin
- Writeln('AsyncRequester :',mes);
- rc:=RETURN_WARN;
- end;
-
- if req<>NIL then FreeSysRequest(req);
- if IntuitionBase<>NIL then CloseLibrary(pLibrary(IntuitionBase));
-
- halt(rc);
- end;
-
- procedure OpenLibs;
- begin
- IntuitionBase:=pIntuitionBase(OpenLibrary('intuition.library',36));
- if IntuitionBase=NIL then Cleanup('Can''t open intuition.library V36!');
- end;
-
- procedure StartRequester;
- begin
- es.es_StructSize:=sizeof(tEasyStruct);
- es.es_Flags:=0;
- es.es_Title:=@ReqTitle[1];
- es.es_TextFormat:=@ReqBody[1];
- es.es_GadgetFormat:=@ReqGadgets[1];
-
- req:=BuildEasyRequestArgs(IntuitionBase^.ActiveWindow,@es,0,NIL);
- if req=NIL then Cleanup('Can''t open requester!?');
- end;
-
- procedure HandleAll;
- var
- ok : boolean;
- l : long;
- c : long;
- begin
- c:=0;
- ok:=FALSE;
- repeat
- Delay_(10);
- l:=SysReqHandler(req,NIL,FALSE);
-
- if l=1 then
- begin
- writeln('Requester replied: You clicked on "PPC Amiga"');
- ok:=TRUE;
- end else if l=0 then begin
- writeln('Requester replied: You clicked on "B. Gates going bankrupt"');
- ok:=TRUE;
- end else if CheckSignal(SIGBREAKF_CTRL_C)=SIGBREAKF_CTRL_C then
- begin
- writeln('** BREAK: Requester has not been replied!');
- ok:=TRUE;
- end else begin
- Writeln('NOOP Counter :',c);
- Inc(c);
- end;
- until ok;
- end;
-
- begin
- OpenLibs;
- StartRequester;
- HandleAll;
- Cleanup('');
- end.